<template>
  <div id="riskChart" style="width: 100%; height: 100%"></div>
</template>

<script>
import * as echarts from "echarts";
import { getDetailInfo} from '@/api/applicationService/terminal.js'

export default {
  name: "riskChart",
  props: {
    data: {
      type: Array,
      default: () => [],
    },
 
  },
  mounted() {
    //发送网络请求获取数据
    let id = this.$route.query.id

    getDetailInfo(id).then(res => {
        if(res.code == 200 && res.data){
    this.initEcharts(res.data);
        }else{
            this.$message.error(res.message)
        }
    });
  },
  methods: {
    initEcharts(dataList) {
      const myChart = echarts.init(document.getElementById("riskChart"));
      let option = {
        legend: {
          top: "bottom",
        },
        toolbox: {
          show: true,
          feature: {
            mark: { show: true },
            dataView: { show: true, readOnly: false },
            restore: { show: true },
            saveAsImage: { show: true },
          },
        },
        series: [
          {
            name: "Nightingale Chart",
            type: "pie",
            radius: [50, 250],
            center: ["50%", "50%"],
            roseType: "area",
            itemStyle: {
              borderRadius: 8,
            },
            data: dataList,
          },
        ],
      };
      myChart.setOption(option);
    },
  },
};
</script>
